package com.example.student.controller;

import com.example.student.pojo.Classes;
import com.example.student.pojo.PageBean;
import com.example.student.pojo.Result;
import com.example.student.pojo.Stu;
import com.example.student.service.ClassService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController

public class ClassController {
    @Autowired
    private ClassService classService;

    @GetMapping("/class")
    public Result page(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer pageSize) {
        PageBean pageBean=classService.pages(page,pageSize);
        return Result.success(pageBean);
    }
//删除班级
    @DeleteMapping("/class/{id}")
    public Result delete(@PathVariable Integer id) {
        log.info("根据{}删除班级",id);
        classService.delete(id);
        return Result.success();}

    //添加班级
    @PostMapping("/class")
    public Result addDept(@RequestBody Classes cla) {
        log.info("新增班级:{}",cla);
        return classService.add(cla);
    }

}
